<template>
  <view class="craftsman-info">
    <view class="page-container">
      <view class="top-name">
        {{ pageInfo.storeName }}
      </view>

      <view class="info">
        {{ serviceLabelList }}
      </view>

      <view class="more-info flex flex-middle flex-left">
        <view class="price flex flex-middle">
          {{ `￥${pageInfo.price || 0}` }}
          <text>起</text>
        </view>
        <view class="num">
          {{ `月售 ${pageInfo.sales || 0}` }}
        </view>
      </view>

      <view class="rich-text-container">
        <view class="title"> 项目特色 </view>
        <view class="content" :class="{ hide: !showMore }" ref="content">
          {{ pageInfo.serviceSpecial || "暂无介绍" }}
        </view>
        <view
          class="show-more flex flex-middle flex-center"
          @click="showMore = !showMore"
          v-if="pageInfo.serviceSpecial && pageInfo.serviceSpecial.length > 116"
        >
          {{ showMore ? "收起简介" : "展开更多" }}
          <u-icon
            class="icon"
            size="16"
            color="#666"
            :name="showMore ? 'arrow-up' : 'arrow-down'"
          />
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    pageInfo: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      showMore: false,
    };
  },
  computed: {
    serviceLabelList() {
      return this.pageInfo.serviceLabelList?.join(" | ");
    },
  },
};
</script>

<style scoped lang="scss">
.craftsman-info {
  padding: 16px 16px 6px;
  border-bottom: 10px solid #f6f6f6;
}

.show-more {
  font-size: 12px;
  color: #31bc4e;
  height: 28px;

  .icon {
    margin-left: 2px;
  }
}

.rich-text-container {
  margin-top: 18px;

  .hide {
    max-height: 68px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
  }

  .content::after {
    text-align: justify;
  }

  .content {
    border-top: 1px solid #f6f6f6;
    border-bottom: 1px solid #f6f6f6;
    padding: 6px 0;
    line-height: 18px;
    color: #333;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .title {
    color: #333;
    padding-bottom: 10px;
  }
}

.more-info {
  margin-top: 12px;

  .num {
    font-size: 12px;
    color: #333;
    margin-left: 8px;
  }

  .price {
    color: #ed6041;
    font-size: 18px;

    text {
      font-size: 12px;
      margin-left: 2px;
    }
  }
}

.info {
  color: #9d9d9d;
  font-size: 12px;
  margin-top: 12px;
}

.top-name {
  color: #222;
  font-size: 18px;
}
</style>